<template>
  <view class="demo-container">
    <!-- 文字提示 -->
    <view class="demo-block">
      <view class="demo-block__title">文字提示</view>
      <view class="demo-block__content">
        <fu-button type="primary" @click="showTextToast">文字提示</fu-button>
        <fu-toast
          v-model:show="show1"
          message="这是一条提示消息"
        />
      </view>
    </view>
    
    <!-- 加载提示 -->
    <view class="demo-block">
      <view class="demo-block__title">加载提示</view>
      <view class="demo-block__content">
        <fu-button type="primary" @click="showLoadingToast">加载提示</fu-button>
        <fu-toast
          v-model:show="show2"
          type="loading"
          message="加载中..."
          :duration="0"
        />
      </view>
    </view>
    
    <!-- 成功提示 -->
    <view class="demo-block">
      <view class="demo-block__title">成功提示</view>
      <view class="demo-block__content">
        <fu-button type="primary" @click="showSuccessToast">成功提示</fu-button>
        <fu-toast
          v-model:show="show3"
          type="success"
          message="操作成功"
        />
      </view>
    </view>
    
    <!-- 不同位置 -->
    <view class="demo-block">
      <view class="demo-block__title">不同位置</view>
      <view class="demo-block__content">
        <fu-button type="primary" @click="showTopToast" class="button-item">顶部展示</fu-button>
        <fu-button type="primary" @click="showBottomToast" class="button-item">底部展示</fu-button>
        <fu-toast
          v-model:show="show4"
          message="顶部展示"
          position="top"
        />
        <fu-toast
          v-model:show="show5"
          message="底部展示"
          position="bottom"
        />
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      show1: false,
      show2: false,
      show3: false,
      show4: false,
      show5: false
    }
  },
  methods: {
    showTextToast() {
      this.show1 = true
    },
    showLoadingToast() {
      this.show2 = true
      setTimeout(() => {
        this.show2 = false
      }, 2000)
    },
    showSuccessToast() {
      this.show3 = true
    },
    showTopToast() {
      this.show4 = true
    },
    showBottomToast() {
      this.show5 = true
    }
  }
}
</script>

<style lang="scss" scoped>
.demo-container {
  padding: 20rpx;
}

.demo-block {
  margin-bottom: 30rpx;
  
  &__title {
    margin-bottom: 20rpx;
    font-size: var(--fu-font-size-lg);
    color: var(--fu-text-color);
  }
  
  &__content {
    background-color: #fff;
    border-radius: var(--fu-radius-base);
    overflow: hidden;
    padding: 30rpx;
  }
}

.button-item {
  margin-right: 20rpx;
  
  &:last-child {
    margin-right: 0;
  }
}
</style> 